<template>

	<view class="searchPage">
		<view class="backGroundBox">

		</view>
		<view class="resultBottomShell">
			<!-- 标题 -->
			<view class="shell">
				<view class="tabShell">
					<view class="tabSmallShell" @click.stop="switchTab(0)">
						<view :class="active == 0 ?'textActive':'text'"> 全部 </view>
						<view class="redLine" v-if="active==0"></view>
					</view>
					<view class="tabSmallShell" @click.stop="switchTab(1)">
						<view class="textShell">
							<view :class="active == 1 ?'textActive':'text'"> 销量 </view>
							<view class="descIconShell" :class="saleDesc?'':'rotateCss'">
								<image class="activeDescIcon" src="/static/image/selectTop.png">
								</image>
								<image class="grayDescIcon"  src="/static/image/selectDown.png">
								</image>
							</view>
						</view>
						<view class="redLine" v-if="active==1"></view>
					</view>
					<!-- 	<view class="tabSmallShell" @click.stop="switchTab(2)">
						<view class="textShell">
							<view :class="active == 2 ?'textActive':'text'"> 价格 </view>
							<view class="descIconShell" :class="saleDesc?'':'rotateCss'">
								<image class="activeDescIcon" src="/static/image/selectTop.png"></image>
								<image class="grayDescIcon" src="/static/image/selectDown.png"></image>
							</view>
						</view>
						<view class="redLine" v-if="active==2"></view>
					</view> -->
				</view>
			</view>
			<view style="height: 100rpx;"></view>
			<!-- 下方商品 -->
			<view class="bottomShell" v-if="list.length>0">
				<!--  -->
				<block v-for="(item,index) in list" :key="index">
					<view class="item">
						<view class="goodsContent">
							<view class="nameShell">
								<view class="goodsName">{{item.deviceName}}</view>
								<view class="radioFlex">
									<view class="radioBox" v-if="item.network == 1">

									</view>
									<view class="radioBox" style="background: gray;" v-else>

									</view>
									<view class="price">{{item.workName}}</view>

								</view>
							</view>
							<view class="property">{{item.address}}</view>
							<view class="saleShell">
								<view class="saleText">当前柜内商品 <text class="redText">{{item.stockNumber}}</text> 瓶</view>
								<view class="saleText">本月销量 <text class="redText">{{item.salesVolume}}</text> 瓶</view>
							</view>

						</view>
					</view>
				</block>
			</view>
			<view class="nothingTipShell" v-else>
				<image class="nothingIcon" src="/static/image/searchNothing.png"></image>
				<view class="tip1">没有搜索结果</view>
				<view class="tip2">没有找到相关产品</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				statusHeight: 0, //状态栏
				active: 0, //标题索引
				searchContent: "", //搜索内容
				list: [],
				pageSize: 10,
				pageNumber: 1,
				sort: '',
				isLoadMore: false,
				saleDesc: true
			}
		},
		onReady() {
			this.statusHeight = getApp().globalData.statusBarHeight
		},
		onLoad() {
			this.getData()
		},
		onReachBottom() {
			if (this.isLoadMore) {
				this.pageNumber += 1
				this.getData()
			}
		},
		methods: {
			sortClick(sort) {
				this.sort = sort ? sort : 3
				// console.log(sort)
				this.list = []
				this.getData()
			},
			getData() {
				this.http({
					url: '/Main/salesVolume',
					data: {
						pageSize: this.pageSize,
						pageNumber: this.pageNumber,
						sort: this.sort
					},
					method: "POST",
					success: res => {
						if (res.code == 200) {
							this.list = this.list.concat(res.data.list)
							if (res.data.list.length < this.pageSize) {
								this.isLoadMore = false
							} else {
								this.isLoadMore = true
							}
						}
					}
				})
			},
			// 搜索结果页的tab切换标题
			switchTab(current) {
				this.pageNumber = 1
				this.list = []
				this.active = current //选中当前筛选项
				if (current == 0) {
					this.sort = 1
				} else if (current == 1) {
					this.saleDesc = !this.saleDesc
					// this.sort = 3
					this.sort = this.saleDesc ? 2 : 3
					// this.sortClick()
				} else {
					// this.sort = 5
				}
				this.getData()
			},
			// 点击选择
			selectHandle(item) {
				uni.navigateTo({
					url: "/pages/setRemined/resultPage/resultPage"
				})
			},
			// 点击返回
			goBack() {
				uni.navigateBack({
					delta: 1
				})
			}
		}
	}
</script>

<style scoped>
	.bg {
		width: 100vw;
		height: 100vh;
		position: fixed;
		top: 0;
		left: 0;
		background: linear-gradient(180deg, #F5F5F5 0%, #FFFFFF 100%);
		z-index: -1;
	}

	.navShell {
		width: 100%;
		box-sizing: border-box;
		padding: 10rpx 40rpx;
		/* width: 65%; */
		position: fixed;
		z-index: 9999;
		background-color: #FFFFFF;
		height: auto;
		display: flex;
		align-items: center;
	}

	.navSearch {
		width: 60%;
		border: 1px solid #E32929;
		border-radius: 76rpx;
		height: 76rpx;
		line-height: 76rpx;
		display: flex;
		justify-content: space-between;
		margin-left: 30rpx;
	}

	.backIcon {
		width: 20rpx;
		height: 32rpx;
	}

	.navInput {
		display: flex;
		align-items: center;
		padding: 0 28rpx;
		justify-content: space-between;
	}

	.input {
		width: 75%;
		margin-top: -5rpx;
		/* border: 1px solid #007AFF; */

	}

	.redText {
		font-size: 36rpx;
		font-family: PingFang SC;
		font-weight: 400;
		color: #E32929;
	}

	.clearIcon {
		width: 32rpx;
		height: 32rpx;
		/* margin-left: 10rpx; */
	}

	.searchIcon {
		width: 24rpx;
		height: 24rpx;
		margin-right: 10rpx;
	}


	.placeCss {
		font-size: 28rpx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: rgba(0, 0, 0, 0.45);
		opacity: 1;
	}

	.shell {
		width: 100%;
		height: 100rpx;
		position: fixed;
		background-color: #FFFFFF;
		box-sizing: border-box;
		padding-bottom: 30rpx;
		padding-left: 40rpx;
		z-index: 999;
	}

	.tabShell {
		display: flex;
		width: 60%;
		height: 80rpx;
		justify-content: space-between;
		align-items: center;
	}

	.tabSmallShell {
		display: flex;
		flex-direction: column;
	}

	.textShell {
		display: flex;
		align-items: center;
	}

	.descIconShell {
		width: 10rpx;
		height: 20rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: space-between;
		margin-left: 6rpx;
	}

	.activeDescIcon,
	.grayDescIcon {
		width: 10rpx;
		height: 8rpx;
		display: block;
	}

	.rotateCss {
		transform: rotate(180deg);
	}

	.text,
	.title {
		font-size: 28rpx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: rgba(0, 0, 0, 0.45);
		/* margin-top: 15rpx; */
	}

	.title {
		margin-top: 10rpx;
	}

	.textActive {
		font-size: 40rpx;
		font-family: Source Han Sans CN;
		font-weight: bold;
		color: rgba(0, 0, 0, 0.65);
	}

	.redLine {
		width: 100%;
		height: 8rpx;
		background-color: #E32929;
	}

	.bottomShell {
		width: 100%;
		box-sizing: border-box;
		padding: 20rpx 40rpx;
		background: #f6f6f6;
	}


	.nothingTipShell {
		width: 50%;
		margin: 35% auto;
		border: #007AFF;
	}

	.nothingIcon {
		width: 180rpx;
		height: 180rpx;
		display: block;
		margin: 0 auto;
	}

	.tip1 {
		width: 100%;
		text-align: center;
		font-size: 36rpx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: #000000;
		margin-top: 30rpx;
	}

	.tip2 {
		width: 100%;
		text-align: center;
		font-size: 32rpx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: rgba(0, 0, 0, 0.4);
		margin-top: 30rpx;
	}


	.item {
		width: 100%;
		box-sizing: border-box;
		padding: 20rpx;
		border-radius: 10rpx;
		background-color: #FFFFFF;
		display: flex;
		align-items: center;
		margin-top: 8rpx;
		justify-content: space-between;
	}

	.goodsImg {
		width: 160rpx;
		height: 160rpx;
		display: block;
	}

	.goodsContent {
		width: 100%;
	}

	.nameShell {
		display: flex;
		align-items: center;
	}

	.goodsName,
	.price,
	.saleText {
		font-size: 28rpx;
		font-family: Source Han Sans CN;

	}

	.goodsName {
		width: 80%;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		font-size: 32rpx;
		font-family: Source Han Sans CN;
		font-weight: 500;
		color: #000000;
	}

	.price {
		font-weight: 500;
		font-size: 28rpx;
		font-family: Source Han Sans CN;
		color: rgba(0, 0, 0, 0.65);
	}

	.property {
		font-size: 28rpx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: rgba(0, 0, 0, 0.65);
		margin-top: 30rpx;

	}

	.saleShell {
		width: 100%;
		display: flex;
		align-items: flex-end;
		justify-content: space-between;
		font-size: 28rpx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: rgba(0, 0, 0, 0.65);
		margin-top: 5rpx;
		/* justify-content: space-between; */
	}

	.saleText {
		font-weight: 400;
	}

	.selectButton {
		padding: 10rpx 20rpx;
		text-align: center;
		border-radius: 4rpx;
		background-color: #E32929;
		font-size: 32rpx;
		font-family: Source Han Sans CN;
		font-weight: 500;
		color: #FFFFFF;
	}

	.radioBox {
		width: 14rpx;
		height: 14rpx;
		background: #0AAB24;
		border-radius: 50%;
		margin-right: 5rpx;
	}

	.radioFlex {
		display: flex;
		align-items: center;
	}

	.backGroundBox {
		position: fixed;
		z-index: -1;
		width: 100vw;
		height: 100vh;
		top: 0;
		left: 0;
		background: #f5f5f5;
	}
</style>
